<template>
  <div class='student'>
    <h3>学生名称：{{name}}</h3>
    <h3>学生年龄：{{age}}</h3>
    <h3>学生性别：{{sex}}</h3>
    <button @click="sendStudentName">把学生姓名给School</button>
  </div>
</template>

<script>
 
export default {
     name:"Student",
     data() {
        return {
            name:'小莫',
            age:22,
            sex:"男",
        }
     },
    //  mounted() {
    //       console.log(this.$bus);
    //  },
     methods: {
          sendStudentName(){
            //触发的自定事件
               this.$bus.$emit('hello',this.name)
          }
     },
}
</script>

<style scoped>
    .student{
        background-color:aqua;
        margin: 20px 5px;
        padding: 5px;
    }
</style>